package com.gym.code.generator.model.mapping.bean;

import java.util.ArrayList;
import java.util.List;

import com.gym.code.generator.model.mapping.BaseGenerateModel;
import com.gym.code.generator.utils.LocalStringUtils;

/**
 * 
 * @author xinchun.wang
 * @email: 532002108@qq.com
 * @createTime 2015-4-14 上午11:57:50
 */
public class EnumGenerateModel  extends BaseGenerateModel{

	private EnumMapping enumMapping;
	private String enumTypeName;
	private EnumScope scope = EnumScope.local;

	private EnumValuePattern valuePattern = EnumValuePattern.keyValue;
	public EnumMapping getEnumMapping() {
		if(enumMapping == null){
			enumMapping = new EnumMapping();
		}
		return enumMapping;
	}

	
	public void setEnumMapping(EnumMapping enumMapping) {
		this.enumMapping = enumMapping;
	}


	public String getEnumTypeName() {
		return enumTypeName;
	}

	public String getEnumTypeNameByFirstLetterUpper() {
		return LocalStringUtils.toFirstLetterUpper(enumTypeName);
	}
	
	public void setEnumTypeName(String enumTypeName) {
		this.enumTypeName = enumTypeName;
	}

	
	public EnumScope getScope() {
		return scope;
	}

	public void setScope(EnumScope scope) {
		this.scope = scope;
	}

	
	public EnumValuePattern getValuePattern() {
		return valuePattern;
	}

	public void setValuePattern(EnumValuePattern valuePattern) {
		this.valuePattern = valuePattern;
	}

	@Override
	protected String getFileName() {
		return enumTypeName;
	}
	
	
	@Override
	public String getPackageName() {
		return packagePath  + ".bean";
	}

	public static class EnumMapping {
		
		private List<EnumMappingItem> enumList;

		public List<EnumMappingItem> getEnumList() {
			if (enumList == null) {
				enumList = new ArrayList<EnumMappingItem>();
			}
			return enumList;
		}
	}

	public static class EnumMappingItem {
		private String enumName;
		private int value ;
		private String desc;

		
		public EnumMappingItem(int value,String enumName,String desc){
			this.enumName = enumName;
			this.value = value;
			this.desc = desc;
		}
		
		public EnumMappingItem(String enumName,int value,String desc){
			this.enumName = enumName;
			this.value = value;
			this.desc = desc;
		}
		
		public String getEnumName() {
			return enumName;
		}

		public void setEnumName(String enumName) {
			this.enumName = enumName;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

		public String getDesc() {
			return desc;
		}

		public void setDesc(String desc) {
			this.desc = desc;
		}
	}
	
	public static enum EnumScope{
		none(2),local(0),global(1);
		private int id;
		
		private EnumScope(int id){
			this.id = id;
		}

		public int getId() {
			return id;
		}
	}
	
	
	public static enum EnumValuePattern{
		simple(),keyValue();
		private EnumValuePattern(){}
	}

}
